#ifndef __THREADPOOL_H__
#define __THREADPOOL_H__
#include "TaskQueue.h"
#include <iostream>
#include <vector>
#include <thread>
#include <functional>

using std::vector;
using std::thread;
using std::function;


using Task = function<void()>;
class ThreadPool
{
public:
    ThreadPool(size_t threadNum, size_t queSize);
    ~ThreadPool(){}
    void start();//启动线程池
    void stop(); //终止线程池
    void addTask(Task &&ptask);//添加任务到任务队列

private:
    Task getTask();//任务队列中获取任务
    void doTask();  //执行任务

    size_t _threadNum; //线程数量
    vector<thread> _threads;//线程
    size_t _queSize;  //任务队列大小
    TaskQueue _taskQue;//任务队列
    bool _isExit;   //线程池退出标志
};



#endif
